<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\common\model;

use app\common\model\Base;
use think\Db;

class SystemUser extends Base {

    /**
     * @title 注册
     * @param type $post
     * @return type
     */
    public function reg($post) {

        $data['username'] = $post['username'] ?? '';
        $data['nickname'] = $post['nickname'] ?? '';
        $data['password'] = $post['password'] ?? '';
        $data['create_time'] = time();
        $data['update_time'] = time();


        $insert_id = db('system_user')->insertGetId($data);

        return $insert_id;
    }
    
    public function model_where() {



        if (request()->get('keyword'))
            $this->where('nickname', 'like', '%' . request()->get('keyword') . '%');

        $this->order('id desc');

        return $this;
    }

}
